package com.test.freemarker.controller;

import com.test.freemarker.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.*;

@Controller
public class HelloController {

    @GetMapping("/basic")
    public String test(Model model) {


        //1.纯文本形式的参数
        model.addAttribute("name", "freemarker");
        model.addAttribute("title", "freemarker测试");
        //2.实体类相关的参数

        Student student = new Student();
        student.setName("小明");
        student.setAge(18);
        model.addAttribute("stu", student);

        List<Student> students = new ArrayList<>();
        students.add(student);
        Student student1 = new Student();
        student1.setName("小王");
        student1.setAge(19);
        student.setMoney(1000.01f);
        student1.setMoney(1000.02f);
        students.add(student1);
        model.addAttribute("stus", students);

        Map<String,Student> map = new HashMap<>();
        map.put("stu1",student);
        map.put("stu2",student1);
        model.addAttribute("map", map);

        Date today = new Date();
        model.addAttribute("today", today);

        model.addAttribute("number", 13841994133L);
        return "01-basic";
    }
}
